set more off
capture log close
global dir "directory"
/***********************************************************************
PROGRAM:	06_MJW_Elig.do
PURPOSE:    This program looks at changes in Medicaid eligibility with
			the ACA expansions for Miller, Alketruse, Johnson, and Wherry
DATE:		April 10, 2019
LAST UPDATED:		October 30, 2020 to add new age groups
NOTES:		Uses ACS extract cleaned in 05_MJW_Cov.do
************************************************************************/
global final "$dir/local/finaldata"
global temp "$dir/local/tempdata"
global indata "$dir/acamort/indata"
global output "$dir/acamort/output"
global build "$dir/acamort/build"

***(1) Read-in adult eligibility thresholds, see source information and
*** 	 additional notes in Appendix Table 1
import excel using "$indata/elig_thresh_clean.xlsx", first clear
expand 10
bysort fips: gen year=2007+_n
gen adulim=.
forval x=2008/2010{
	replace adulim=adu`x' if year==`x'
}
forval x=2011/2017{
	replace adulim=adu`x'_01 if year==`x'
}
replace adulim=1.39 if year==2015 & fips==18
gen parlim=.
foreach x in 2008 2009 2011 2012 2013 2014 2015 2016 2017 {
	replace parlim=par`x'_01 if year==`x'
}
replace parlim=par2009_12 if year==2010
replace parlim=1.39 if year==2015 & fips==18

keep fips year parlim adulim
label var fips "State FIPS code"
label var year "Year"
label var adulim "Adult Medicaid eligiblity limit"
label var parlim "Parental Medicaid eligibility limit"
save "$build/adultelig", replace

***(2) Prepare ACS for eligibility imputation
use "$final/acs1ststage", clear
replace cbserial=cbserial-2017000000000 if year==2017
egen hhid=concat(year cbserial)
rename cbpernum pnum
duplicates report hhid pnum
gen rel=""
gen sfr=""
gen sfn=""
gen msp=""
forval x=2008/2017{
	if `x'<2011{
		replace rel=us`x'a_rel if year==`x'
	}
	if `x'>=2011{
		replace rel=us`x'a_relp if year==`x'
	}
	replace sfr=us`x'a_sfr if year==`x'
	replace sfn=us`x'a_sfn if year==`x'
	replace msp=us`x'a_msp if year==`x'
}
foreach x in sfr sfn {
	replace `x'="0" if `x'=="B"
}
destring rel sfr sfn msp, replace
rename momloc momlocipums
rename poploc poplocipums
rename sploc splocipums

gen child=age<18
gen momlocn=0
gen poplocn=0
gen splocn=0

**a) use rel var to id parent-child relationships
gen dum=(rel==0 & sex==2)
bys hhid: egen fhh=max(dum)
drop dum
gen dum=(rel==0 & sex==1)
bys hhid: egen mhh=max(dum)
drop dum
gen dum=(rel==1 & sex==2)
bys hhid: egen fsp=max(dum)
drop dum
gen dum=(rel==1 & sex==1)
bys hhid: egen dsp=max(dum)
drop dum

gen dum=rel==0
replace dum=dum*pnum
bys hhid: egen hhp=max(dum)
drop dum
gen dum=rel==1
replace dum=dum*pnum
bys hhid: egen spp=max(dum)
drop dum

replace poplocn=hhp if mhh & inrange(rel,2,4)
replace momlocn=hhp if fhh & inrange(rel,2,4)
replace momlocn=spp if fsp & inrange(rel,2,4)
replace poplocn=spp if dsp & inrange(rel,2,4)

gen dum=(rel==6 & sex==2)
bys hhid: egen fpar=max(dum)
replace dum=dum*pnum
bys hhid: egen farp=max(dum)
drop dum
gen dum=(rel==6 & sex==1)
bys hhid: egen mpar=max(dum)
replace dum=dum*pnum
bys hhid: egen marp=max(dum)
drop dum

replace momlocn=farp if fpar & inlist(rel,0,5)
replace poplocn=marp if mpar & inlist(rel,0,5)

gen dum=(rel==8 & sex==2)
bys hhid: egen finl=max(dum)
replace dum=dum*pnum
bys hhid: egen finlp=max(dum)
drop dum
gen dum=(rel==8 & sex==1)
bys hhid: egen minl=max(dum)
replace dum=dum*pnum
bys hhid: egen minlp=max(dum)
drop dum

replace momlocn=finlp if finl & inlist(rel,1)
replace poplocn=minlp if minl & inlist(rel,1)

**b) use subfamily relationships to id parent-child relationships
egen famid=concat(hhid sfn)
gen dum=(sfr==3 & sex==2)
bys famid: egen parf=max(dum)
replace dum=dum*pnum
bys famid: egen parfp=max(dum)
drop dum
gen dum=(sfr==3 & sex==1)
bys famid: egen parm=max(dum)
replace dum=dum*pnum
bys famid: egen parmp=max(dum)
drop dum

replace momlocn=parfp if parf & sfr==5
replace poplocn=parmp if parm & sfr==6

gen dum=(sfr==2 & sex==2)
bys famid: egen marcf=max(dum)
replace dum=dum*pnum
bys famid: egen marcfp=max(dum)
drop dum
gen dum=(sfr==2 & sex==1)
bys famid: egen marcm=max(dum)
replace dum=dum*pnum
bys famid: egen marcmp=max(dum)
drop dum

replace momlocn=marcfp if marcf & sfr==4
replace poplocn=marcmp if marcm & sfr==4

**c) use rel to id spousal relationships
gen dum=rel==1
bys hhid: egen sphh=max(dum)
replace dum=dum*pnum
bys hhid: egen sphhp=max(dum)
drop dum
gen dum=rel==0
replace dum=dum*pnum
bys hhid: egen sphhp2=max(dum)
drop dum

replace splocn=sphhp if rel==0 & sphh
replace splocn=sphhp2 if rel==1 & sphh

**d) use sfr to id spousal relationships
gen dum=inlist(sfr,1,2)
bys famid: egen spfam=max(dum)
drop dum
sort famid sfr pnum
bys famid sfr: gen count=_n
su count if inlist(sfr,1,2)
gen dum=(inlist(sfr,1,2) & count==1)
replace dum=dum*pnum
bys famid: egen sphfamp=max(dum)
drop dum
gen dum=(inlist(sfr,1,2) & count==2)
replace dum=dum*pnum
bys famid: egen sphfamp2=max(dum)
drop dum

replace splocn=sphfamp if inlist(sfr,1,2) & count==2
replace splocn=sphfamp2 if inlist(sfr,1,2) & count==1
drop count

**e) count number of own children
rename nchild nchildipums
save "$final/acs1stelig", replace
keep if momlocn!=0
keep hhid momlocn
rename momlocn pnum
gen ob=1
collapse (sum) nchild=ob, by(hhid pnum)
merge 1:1 hhid pnum using "$final/acs1stelig", keep(match using) nogen
save "$final/acs1stelig", replace
keep if poplocn!=0
keep hhid poplocn
rename poplocn pnum
gen ob=1
collapse (sum) nchild2=ob, by(hhid pnum)
merge 1:1 hhid pnum using "$final/acs1stelig", keep(match using) nogen
replace nchild=nchild2 if nchild==.
replace nchild=0 if nchild==.
drop nchild2

**f) create HIUD unit following SHADAC code
destring msp, replace force
gen echild=(age<=18 & !inlist(msp,1,2) & nchild==0)
lab var echild "Eligible to be linked to HIU as child"
gen rel_echild=(echild==1 & inrange(rel,2,10))
lab var rel_echild "Related eligible child"

gen hiup=.
replace hiup=1 if (msp==1 & sex==1) | (sex==1 & nchild>0 & msp!=1) | ///
(sex==2 & nchild>0 & msp!=1)
replace hiup=2 if (msp==1 & sex==2)
replace hiup=3 if echild==1 & (poplocn!=0 | momlocn!=0)
replace hiup=4 if msp!=1 & echild==0 & nchild==0
replace hiup=5 if echild==1 & hiup==. & rel_echild==1
replace hiup=6 if echild==1 & hiup==. & rel_echild==0
lab var hiup "HIU Person Type"

gen hiu_ref=(hiup==1)
lab var hiu_ref "HIU reference person"

egen hiu_refhhld=max(hiu_ref), by(hhid)
lab var hiu_refhhld "HIUP==1 is present in hh"

egen first_hiuref=min(pnum) if hiup==1, by(hhid)
egen first_point=min(first_hiuref), by(hhid)

replace first_point=1 if first_point==.
lab var first_point "Point to first HIU ref of hh"

gen hiu_point_rule=.
gen hiu_point=pnum if hiup==1
replace hiu_point_rule=1 if hiu_point!=.

replace hiu_point=splocn if hiup==2 & splocn>0
replace hiu_point=pnum if hiup==2 & splocn==0
replace hiu_point_rule=2 if hiu_point !=. & hiu_point_rule==.

replace hiu_point=poplocn if hiup==3 & hiu_point==. & poplocn!=0
replace hiu_point_rule=3 if hiu_point!=. & hiu_point_rule==.

replace hiu_point=momlocn if hiup==3 & hiu_point==. & momlocn!=0
replace hiu_point_rule=4 if hiu_point!=. & hiu_point_rule==.

replace hiu_point=pnum if hiup==4
replace hiu_point_rule=5 if hiu_point!=. & hiu_point_rule==.

replace hiu_point=first_point if hiup==5
replace hiu_point_rule=6 if hiu_point!=. & hiu_point_rule==.

replace hiu_point=pnum if hiup==6
replace hiu_point_rule=7 if hiu_point!=. & hiu_point_rule==.

lab var hiu_point "HIU ref pointer"
lab var hiu_point_rule "HIU pointer rule"

tostring (hiu_point), gen(hiu_point_s) format(%02.0f)

rename hiuid hiuidipums
egen hiuid=concat(hhid hiu_point_s)
lab var hiuid "HIU ID"

**g) calculate family income based on this definition
drop famid
egen famid=concat(hhid hiuid)
gen kid=1*(inrange(age,0,18))
bysort famid: egen skid=total(kid)
gen parent=skid>0
capture drop famsize
rename hiunpers famsize
gen rinctot=inctot
*ed 7/9/20, corrected code for N/A and inctot
replace rinctot=0 if inctot<0 | inctot==. | inlist(inctot,9999999)
bysort famid: egen finc=total(rinctot)
label var finc "Family income"
recode incwelfr (99999=.), gen(rincwelfr)
bysort famid: egen famafdc=total(rincwelfr)
label var famafdc "Family public assistance income"
recode incsupp (99999=.), gen(rincsupp)
bysort famid: egen famssi=total(rincsupp)
label var famssi "Family SSI income"
replace finc=finc-famafdc-famssi
replace finc=0 if finc<0 | finc==.
label var finc "Family income net of TANF/SSI"
gen fpl=hiufpgbase+(famsize-1)*hiufpginc

***(3) Impute eligibility for adults
*merge on eligibility limits
gen fips=statefip
merge m:1 fips year using "$build/adultelig", keep(match) nogen

gen adultelig=1*((finc/fpl)<=adulim)
gen parelig=1*((finc/fpl)<=parlim & parent)
gen medelig=1*(adultelig | parelig)
replace medelig=0 if newage>=65

save "$final/acs1stelig", replace

*checks to compare to RDC distributions
preserve
keep if inrange(year,2008,2013)
gen newdef=finc/fpl<=1.38
su famsize, d
su newdef, d
su finc, d
su famafdc, d
su famssi, d
su parent
su finc, d
su fpl, d
su skid, d
tab less138 newdef, m row col
count if (lesshs | less138) & citizen!=3 & inrange(newage,55,64) & ~ssi
count if (lesshs | finc/fpl<=1.38) & citizen!=3 & inrange(newage,55,64) & ~ssi
restore

preserve
keep if (lesshs | less138) & citizen!=3 & inrange(newage,55,64) & ~ssi
mean medelig if expand & ~postexp [pw=perwt]
reg medelig postexp i.statefip i.year [pw=perwt], cluster(statefip)
outreg2 using "$output/firststage_elig", append excel bdec(3) ctitle("`x'","age 55-64 target")
reg medelig expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip i.year ///
	[pw=perwt], cluster(statefip)
outreg2 using "$output/firststage_elig", ///
append excel bdec(3) ctitle("`x'","age 55-64 target")
restore

preserve
keep if (lesshs | less138) & citizen!=3 & inrange(newage,19,64) & ~ssi
mean medelig if expand & ~postexp [pw=perwt]
reg medelig postexp i.statefip i.year [pw=perwt], cluster(statefip)
outreg2 using "$output/firststage_elig", append excel bdec(3) ctitle("`x'","age 19-64 target")
reg medelig expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip i.year ///
	[pw=perwt], cluster(statefip)
outreg2 using "$output/firststage_elig", ///
append excel bdec(3) ctitle("`x'","age 19-64 target")
restore


***(4) New exploratory analyses for QJE revision
use "$final/acs1stelig", clear
svyset [pw=perwt]

*look at income distribution in post period for response letter
mean less138 if year>2013 & inrange(age,55,64) & expand

*keep analytic sample
keep if citizen!=3 & !ssi & inrange(newage,55,64) & (lesshs | less138)

*summarize age distribution for uninsured for response letter

svy: mean newage if year<2014, over(uninsured) coefl
estat sd
test _b[c.newage@0bn.uninsured]=_b[c.newage@1.uninsured]


*heterogeneity analyses
preserve
keep if lesshs | less138
mean medelig medicaid uninsured if ~postexp & expand & white & ~hispanic [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year if white & ~hispanic [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","White Non-H")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt] if white & ~hispanic, cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","White Non-H")
}
mean medelig medicaid uninsured if ~postexp & expand & black & ~hispanic [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year if black & ~hispanic [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Black Non-H")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt] if black & ~hispanic, cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Black Non-H")
}
mean medelig medicaid uninsured if ~postexp & expand & other & ~hispanic [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year if other & ~hispanic [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Other Non-H")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt] if other & ~hispanic, cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Other Non-H")
}
mean medelig medicaid uninsured if ~postexp & expand & hispanic [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year if hispanic [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Hispanic")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt] if hispanic, cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Hispanic")
}
mean medelig medicaid uninsured if ~postexp & expand & married [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year if married [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Married")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt] if married, cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Married")
}
mean medelig medicaid uninsured if ~postexp & expand & ~married [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year if ~married [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Not Married")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt] if ~married, cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Not Married")
}
mean medelig medicaid uninsured if ~postexp & expand & female [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year if female [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Female")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt] if female, cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Female")
}
mean medelig medicaid uninsured if ~postexp & expand & ~female [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year if ~female [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Not Female")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt] if ~female, cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Not Female")
}
mean medelig medicaid uninsured if ~postexp & expand & lesshs [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year if lesshs [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Less HS")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt] if lesshs, cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Less HS")
}
restore


*ages 55-61 subsample from main sample
use "$final/acs1stelig", clear
keep if citizen!=3 & !ssi & inrange(newage,55,61)
keep if lesshs | less138
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","ages 55-61")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","ages 55-61")
}

*age subgroups
use "$final/acs1stelig", clear
keep if lesshs | less138
keep if citizen!=3 & !ssi
foreach x in medelig uninsured {
	reg `x' postexp i.statefip i.year [pw=perwt] if inrange(newage,19,29), cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","ages 19-29")
	reg `x' postexp i.statefip i.year [pw=perwt] if inrange(newage,30,39), cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","ages 30-39")
	reg `x' postexp i.statefip i.year [pw=perwt] if inrange(newage,40,49), cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","ages 40-49")
	reg `x' postexp i.statefip i.year [pw=perwt] if inrange(newage,50,54), cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","ages 50-54")
}


*with SHADAC income measures
gen newinc_fpl=finc/fpl
preserve
keep if newinc_fpl<1.38 | lesshs
mean medelig medicaid uninsured if ~postexp & expand [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Main w/SHADAC")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Main w/SHADAC")
}
restore

preserve
keep if lesshs | less138
gen newsample=1*(lesshs | newinc_fpl<1.38)
su newsample
restore

*limit to linc only
preserve
keep if less138
mean medelig medicaid uninsured if ~postexp & expand [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Less than 138%FPL only")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Less than 138%FPL only")
}
restore

*linc with new fam unit
preserve
keep if newinc_fpl<1.38
mean medelig medicaid uninsured if ~postexp & expand [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Less than 138% SHADAC")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Less than 138% SHADAC")
}
restore

*less than 100% FPL only
preserve
keep if newinc_fpl<1
mean medelig medicaid uninsured if ~postexp & expand [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Less than 100% SHADAC")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Less than 100% SHADAC")
}
restore

*very very new sample of "newly eligible" with SHADAC, 11/26
preserve
foreach x of var year medelig adulim parlim adultelig parelig {
	rename `x' `x'old
}
gen year=2013
merge m:1 fips year using "$build/adultelig", keep(match) nogen
gen adultelig=1*((finc/fpl)<=adulim)
gen parelig=1*((finc/fpl)<=parlim & parent)
gen medelig=1*(adultelig | parelig)
replace medelig=0 if newage>=65
keep if (medelig==0 & newinc_fpl<1 & yearold>=2013) | (medeligold==0 & newinc_fpl<1 & yearold<2013)
drop year medelig
rename medeligold medelig
rename yearold year
mean medelig medicaid uninsured if ~postexp & expand [pw=perwt]
foreach x in medelig medicaid uninsured {
	reg `x' postexp i.statefip i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Newly Eligible")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip ///
	i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","Newly Eligible")
}
restore


*old placebo 400%
use "$final/acs1stelig", clear
keep if poverty>=400 & inrange(newage,55,64)
mean medicaid uninsured if expand & ~postexp [pw=perwt]
foreach x of var medicaid uninsured {
	reg `x' postexp i.statefip i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","ages 55-64, 400% FPL (current)")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip i.year ///
	[pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","ages 55-64, 400% FPL (current)")
}

*new placebo 400%
use "$final/acs1stelig", clear
keep if finc/fpl>=4 & inrange(newage,55,64)
mean medicaid uninsured if expand & ~postexp [pw=perwt]
foreach x of var medicaid uninsured {
	reg `x' postexp i.statefip i.year [pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","ages 55-64, 400% SHADAC")
	reg `x' expm_6 expm_5 expm_4 expm_3 expm_2 exp0 exp1 exp2 exp3 i.statefip i.year ///
	[pw=perwt], cluster(statefip)
	outreg2 using "$output/firststage_new", append excel bdec(3) ctitle("`x'","ages 55-64, 400% SHADAC")
}

!gzip "$final/acs1stelig.dta"
